<!doctype html>
<html lang="zh-CN">
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
	<title>登录页面</title>
	<link href="https://lib.baomitu.com/twitter-bootstrap/3.4.1/css/bootstrap.min.css" rel="stylesheet">
	<link href="https://lib.baomitu.com/bootstrap-validator/0.5.3/css/bootstrapValidator.min.css" rel="stylesheet">
</head>
<body>
<div class="logo">
	<img src="{$app_logo|default='/logo.png'}">
</div>
<form class="form-horizontal biao" role="form" id="form" method="post">

	<h4 style="text-align: center;">账号注册</h4>

	<div class="form-group col-sm-12">
		<label for="phone" class="col-sm-2 control-label">手机号</label>
		<div class="col-sm-10">
			<input type="phone" name="phone" class="form-control" id="phone" data-bv-notempty="true" data-bv-notempty-message="手机号不能为空" placeholder="请输入手机号">
		</div>
	</div>
	<div class="form-group col-sm-12 ">
		<label for="yzm" class="col-sm-2 col-xs-12 control-label">验证码</label>
		<div class="col-xs-7 ">
			<input type="text" name="yzm" class="form-control" id="yzm" placeholder="请输入验证码">
		</div>
		<div class="col-sm-3  col-xs-5" style="padding: 0;">
			<button type="button"  id="fa_yzm" class="btn btn-primary" style="width: 88%;">发送验证码</button>
		</div>
	</div>
	<div class="form-group col-sm-12">
		<label for="password" class="col-sm-2 control-label">请输入密码</label>
		<div class="col-sm-10">
			<input type="text" name="password" class="form-control" id="password" data-bv-notempty="true" data-bv-notempty-message="密码不能为空" placeholder="请输入密码">
		</div>
	</div>
	<div class="form-group col-sm-12">
		<label for="password" class="col-sm-2 control-label">确认密码</label>
		<div class="col-sm-10">
			<input type="text" name="password2" class="form-control" id="password2" data-bv-notempty="true" data-bv-notempty-message="确认密码不能为空" placeholder="在输入一遍">
		</div>
	</div>
	<div class="form-group col-sm-12">
		<label for="code" class="col-sm-2 control-label">邀请码</label>
		<div class="col-sm-10">
			<input type="text" name="code" class="form-control" id="code" placeholder="请输入邀请码">
			<span id="code1"></span>
		</div>
	</div>
	<div class="form-group" style="margin-top: 30px;">
		<div class="col-xs-offset-2 col-xs-10">
			<button type="submit" class="btn btn-success" id="btn" style="width: 200px;">登录</button>
		</div>
	</div>
	<div style="text-align: center;color: #ff0000;font-size: 14px;margin-bottom: 10px;">
		如果您有账号，请点击下面按钮下载
	</div>
	<div class="form-group">
		<div class="col-xs-offset-2 col-xs-10">
			<button  class="btn btn-default" onclick="xia()"  style="width: 200px;">下载</button>
		</div>
	</div>
	<footer id="footer" class="col-xs-12" style="margin-top: 30px;text-align: center;">
		<p><span>© 2023 {$app_name} </span><br/><span id='li'  style="color: red;">注意：微信不支持直接下载，请点击右上方三个点，用浏览器打开</span></p>
	</footer>
</form>

<style type="text/css">
	.logo{
		margin: 0 auto;
		width: 300px;
	}
	.logo img{
		width: 100%;
	}
	@media (max-width:767px) {
		.logo {
			width: 100px;
			margin: 0 auto;
			margin-top: 50px;
		}

		.logo img {
			width: 100%;
		}
		.biao{
			margin-top: 50px;
			padding: 0 30px;
		}
	}
</style>

<script src="https://lib.baomitu.com/jquery/1.12.4/jquery.min.js"></script>
<script src="https://lib.baomitu.com/twitter-bootstrap/3.4.1/js/bootstrap.min.js"></script>
<script src="https://lib.baomitu.com/bootstrap-validator/0.5.3/js/bootstrapValidator.js"></script>

<script type="text/javascript">
	$(document).ready(function() {
		$('#form').bootstrapValidator({
			message: 'This value is not valid',
			feedbackIcons: {
				valid: 'glyphicon glyphicon-ok',
				invalid: 'glyphicon glyphicon-remove',
				validating: 'glyphicon glyphicon-refresh'
			},
			submitHandler: function (validator, form, submitButton) {
			},
			fields: {
				phone: {
					message: '手机号错误',
					validators: {
						notEmpty: {
							message: '手机号码不能为空'
						},
						stringLength: {
							min: 11,
							max: 11,
							message: '请输入11位手机号码'
						},
						regexp: {
							regexp: /^1[3|5|6|7|8|9]{1}[0-9]{9}$/,
							message: '请输入正确的手机号码'
						}
					}
				},
				yzm: {
					message: '验证码错误',
					validators: {
						notEmpty: {
							message: '验证码不能为空'
						}
					}
				},
				code: {
					message: '邀请码',
					validators: {
						notEmpty: {
							message: '邀请码不能为空'
						},
					},
				},
			}
		}).on('#btn', function(e) {
			e.preventDefault();
		});




		let w=getPar('f_user_no')
		if(w){
			$('#code').val(w).hide();
			$('#code1').show().html(w);
		}else{
			$('#code').val('').show();
			$('#code1').hide();
		}


	})

	function getPar(par){
		//获取当前URL
		var local_url = document.location.href;
		//获取要取得的get参数位置
		var get = local_url.indexOf(par +"=");
		if(get == -1){
			return false;
		}
		//截取字符串
		var get_par = local_url.slice(par.length + get + 1);
		//判断截取后的字符串是否还有其他get参数
		var nextPar = get_par.indexOf("&");
		if(nextPar != -1){
			get_par = get_par.slice(0, nextPar);
		}
		return get_par;
	}

	$('#fa_yzm').click(()=>{
		let phone=$('#phone').val()
		if(!(/^[1][3|5|6|7|8|9][0-9]{9}$/.test(phone))){
			alert("手机号码有误，请重填");
			return false;
		}
		let html=$('#fa_yzm').text()
		if(html=='重发验证码' || html=='发送验证码'){
			console.log(888)
			$.post(
					"{:url('xia/ajax')}",
					{
						type:'get_yzm',
						phone:phone,
					},
					function(res){
						if(res.code==1){
							let num=60;
							let wo =setInterval(()=>{
								if(num<1){
									$('#fa_yzm').text('重发验证码')
									clearInterval(wo);
								}else{
									$('#fa_yzm').text(num+'秒')
									num--
								}
							},1000)
						}else{
							$('#fa_yzm').text('重发验证码')
							alert('发送短信失败！')
						}
					}
			);
		}
	})

	var ua = navigator.userAgent.toLowerCase();
	var isWeixin = ua.indexOf('micromessenger') != -1;
	if (isWeixin) {
		//alert('微信不支持直接下载，请点击右上方三个点，用浏览器打开');
	}else{
		document.getElementById('li').style.display='none'
	}

	function xia(){
		if (isWeixin) {
			alert('微信不支持直接下载，请点击右上方三个点，用浏览器打开');
		}else{
			window.open('/update/update_{$app_v}.apk')
		}
	}
</script>
</body>

</html>
